home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-24 | 1.1 KB | 59 lines | [TEXT/MPS ] |
- /*
- * UStandAlone.cp
- * based on A5World.cp by Patrick Beard, ©1990 by Patrick C. Beard. All rights reserved.
- *
- * KNOWN BUGS AND SHORTCOMINGS:
- * [none]
- */
-
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
-
- #ifndef __USTANDALONE__
- #include <UStandAlone.h>
- #endif
-
- const long kAppParmsSize = 32;
-
- extern "C" {
- void A5Init(A5Reference);
- long A5Size(void);
- void init_vtbls(void);
- }
-
- inline A5Reference SetA5(A5Reference newA5) { // trivial overloading to avoid typecasting in code
- return (A5Reference)SetA5((long)newA5);
- }
-
- TStandAloneWorld::TStandAloneWorld(Boolean codeFloats):
- fA5WorldSize(A5Size()), fCodeFloats(codeFloats), fTheirA5(nil) {
- (void)LockHigh();
- if (fOurA5 = NewPtr(fA5WorldSize)) {
- A5Init(fOurA5 + fA5WorldSize - kAppParmsSize);
- Enter();
- if (!fCodeFloats)
- init_vtbls();
- Leave();
- }
- Unlock();
- }
-
- TStandAloneWorld::~TStandAloneWorld() {
- Leave();
- if (fOurA5)
- DisposPtr(fOurA5);
- }
-
- void TStandAloneWorld::Enter() {
- fTheirA5 = SetA5(fOurA5 + fA5WorldSize - kAppParmsSize);
- if (fCodeFloats)
- init_vtbls();
- }
-
- void TStandAloneWorld::Leave() {
- if (fTheirA5) {
- (void)SetA5(fTheirA5);
- fTheirA5 = nil;
- }
- }